Skip to content

fix(help): always show GLOBAL FLAGS as the last help section - #1994

Open
jellyfishing2346 wants to merge 1 commit into
fastly:mainfrom
jellyfishing2346:fix/global-flags-commands
Open

jellyfishing2346 wants to merge 1 commit into
fastly:mainfrom
jellyfishing2346:fix/global-flags-commands

Conversation

@jellyfishing2346

Copy link
Copy Markdown

Change summary

Fixes #1656

Help output placed the GLOBAL FLAGS section inconsistently depending on the command:

  • Commands with subcommands (e.g. fastly service --help) showed GLOBAL FLAGS before COMMANDS.
  • Commands without subcommands (e.g. fastly compute publish --help) showed GLOBAL FLAGS last.

This PR moves the GLOBAL FLAGS block below COMMANDS/SUBCOMMANDS in both the compact (--help) and verbose (fastly help <command>) usage templates in pkg/app/usage.go, so it is always the last section before SEE ALSO. Global flags are the least command-specific information, so putting them last keeps the command's own flags and subcommands up front.

Added TestHelpSectionOrder in pkg/app/run_test.go, covering a parent command (service --help), a leaf command (service create --help), and verbose help for a parent command (help service).

After this change:

$ fastly service --help
USAGE
  fastly service <command> [<args> ...]
...
COMMANDS
  create            Create a Fastly service
  ...
GLOBAL FLAGS
  -h, --help             Show context-sensitive help.
  ...
SEE ALSO
  https://www.fastly.com/documentation/reference/cli/service/
$ fastly service create --help
USAGE
  fastly service create [<flags>]
...
OPTIONAL FLAGS
  ...
GLOBAL FLAGS
  ...
SEE ALSO
  https://www.fastly.com/documentation/reference/cli/service/create/

All Submissions:

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?

Changes to Core Features:

  • Have you written new tests for your core changes, as applicable?
  • Have you successfully run tests with your changes locally?

User Impact

Help output is now consistently ordered across all commands: command-specific flags, args and subcommands first, then global flags, then the documentation link. No flags, commands or behaviour change — only the order of sections in help text.

Are there any considerations that need to be addressed for release?

None. No breaking changes. Anything that parses --help text output by section order would see GLOBAL FLAGS move below COMMANDS for parent commands; the machine-readable fastly help --format json output is unaffected.

@jellyfishing2346
jellyfishing2346 requested a review from a team as a code owner November 26, 2026 20:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

In the --help output, the "Global Flags" and "Commands" output order should be consistent

1 participant